home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 845 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  42 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: dak <pierreba@poster.cae.ca>
  3. Newsgroups: comp.std.c++
  4. Subject: double const declarations
  5. Date: 25 Mar 1996 10:09:28 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <Pine.A32.3.91.960325093715.29874A-100000@zorglub.cae.ca>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Mon, 25 Mar 1996 09:45:54 -0500 (EST)
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBVAwUBMVbhY0y4NqrwXLNJAQGmogIAtmlb94IbqpHwSnOeojPLPr2BWNWMzauC
  13.     ezMEPYWCtZr7QtGJ3MhS14bElN49WNjzc58xI00vK/YqbTt60LQevg==
  14.     =T/R0
  15. Originator: austern@isolde.mti.sgi.com
  16.  
  17. I've just encountered a problem in one of our template design and wondered
  18. what could be done about it. It concerns const reference return value from
  19. a templated member function, for example:
  20.  
  21. template <class T> class SmartPtr
  22. {
  23.     // ... whatever:
  24. public:
  25.     const T & Dereference ();
  26. };
  27.  
  28. The problem arise when T is instantiated with a Container of constants:
  29.  
  30. SmartPtr<const int> a;
  31.  
  32. Here we have a double const which is not supported by the compiler, nor the
  33. standard, I believe.  Is there a fix or should we abandon all hope of using
  34. const returns in templates ?
  35. ---
  36. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  37.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  38.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  39.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  40.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  41. ]
  42.